<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AddCollageGoodsPost extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'product_id'=>'required',
            'title'=>'required',
            'people'=>'required',
            'info'=>'required',
            'price'=>'required',
            'date_time'=>'required',
            'sort'=>'required|integer',
            'effective_time'=>'required',
            'temp_id'=>'required',
            'num'=>'required|integer',
        ];
    }

    /**
     * 获取已定义验证规则的错误消息。
     *
     * @return array
     */
    public function messages()
    {
        return [
            'product_id.required' => '必须选择商品',
            'title.required' => '拼团名称必须填写',
            'people.required' => '参团人数不能为空',
            'info.required' => '简介不能为空',
            'price.required' => '拼团价格不能为空',
            'sort.required' => '排序字段不能为空',
            'date_time.required' => '拼团开始结束时间不能为空',
            'effective_time.required' => '拼团订单时效不能为空',
            'temp_id.required' => '模板id不能为空',
            'num.required' => '单次购买数量不能为空',
            'num.integer'=>'单次购买数量只能是数字'
        ];
    }
}
